namespace XEAS.Framework.Security
{
    using System;
    using System.Runtime.CompilerServices;

    public class FileEncryptorEventArgs : IDisposable
    {
        private long _bytesDone;
        private long _bytesTotal;
        private DateTime _endTime;
        private DateTime _startTime;
        public bool Cancel { get; set; }

        public void Dispose()
        {
            this.Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
            }
        }

        ~FileEncryptorEventArgs()
        {
            this.Dispose(false);
        }

        public long BytesDone
        {
            get
            {
                return this._bytesDone;
            }
        }

        internal long BytesDoneInternal
        {
            set
            {
                this._bytesDone = value;
            }
        }

        public double BytesPerSecond
        {
            get
            {
                return (((double) this._bytesDone) / this._endTime.Subtract(this._startTime).TotalSeconds);
            }
        }

        public long BytesTotal
        {
            get
            {
                return this._bytesTotal;
            }
        }

        internal long BytesTotalInternal
        {
            set
            {
                this._bytesTotal = value;
            }
        }

        public DateTime EndTime
        {
            get
            {
                return this._endTime;
            }
        }

        internal DateTime EndTimeInternal
        {
            set
            {
                this._endTime = value;
            }
        }

        public double PercentageDone
        {
            get
            {
                return (double) ((this._bytesDone / this._bytesTotal) * 100L);
            }
        }

        public DateTime StartTime
        {
            get
            {
                return this._startTime;
            }
        }

        internal DateTime StartTimeInternal
        {
            set
            {
                this._startTime = value;
            }
        }

        public TimeSpan TimeLeft
        {
            get
            {
                return TimeSpan.FromSeconds(((double) (this._bytesTotal - this._bytesDone)) / this.BytesPerSecond);
            }
        }
    }
}

